// ----------------------------------
// RSDK Project: Sonic 2 - Boss Attack Plus
// Script Description: Enemy Mode
// Script Author: Tails LP
// ----------------------------------

//-------Aliases-------//

private alias object.value0 : object.timer

// menu selections


//private alias 0 : 

// object states


private alias 0 : EGGMAN
private alias 1 : EGGROBO
private alias 2 : METALSONIC
private alias 3 : KNUCKLES

private alias saveRAM[494] : saved.bossGameMode //7B8 SData.bin
private alias saveRAM[495] : saved.bossType //7BC SData.bin
private alias saveRAM[496] : saved.BossMusic //7C0 SData.bin
private alias saveRAM[497] : saved.Character //7C4 SData.bin
private alias saveRAM[498] : saved.TimeLimit //7C8 SData.bin
private alias saveRAM[499] : saved.superMode //7CC SData.bin

//-------Function declarations-------//

//-------Static Values-------//

//-------Tables-------//




//-------Functions-------//




event ObjectMain

	temp0 = screen.xcenter
	if object.propertyValue == 0
		temp0 -= 128
	else
		temp0 += 128
	endif
	object.ixpos = temp0
	object.iypos = 96

	if object.propertyValue == 0
		object.direction = FLIP_X
	endif

end event

event ObjectDraw
	if object.timer > 7
		object.timer = 0
		object.frame ^= 1
	else
		object.timer++
	endif

	if object.state > 0
		DrawSpriteFX(object.propertyValue, FX_FLIP, object.xpos, object.ypos)
		switch object.propertyValue
		case 0
			switch saved.bossType
			case EGGMAN
				temp0 = object.frame
				temp0 += 2
				DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
				break
			case EGGROBO
				DrawSpriteFX(6, FX_FLIP, object.xpos, object.ypos)
				break
			endswitch
			break
		case 1
			switch saved.bossType
			case EGGMAN
				temp0 = object.frame
				temp0 += 4
				DrawSpriteFX(temp0, FX_FLIP, object.xpos, object.ypos)
				break
			case EGGROBO
				DrawSpriteFX(7, FX_FLIP, object.xpos, object.ypos)
				break
			endswitch
			break
		endswitch
	endif

end event

event ObjectStartup
	ReadSaveRAM()
	LoadSpriteSheet("LevelSelect/Icons.gif")
	SpriteFrame(-32, -17, 64, 35, 250, 91)			//00 Egg Mobile S1
	SpriteFrame(-32, -14, 64, 29, 226, 208)			//01 Egg Mobile S2

	SpriteFrame(-32, -38, 64, 21, 250, 47)			//02 Eggman 1 S1
	SpriteFrame(-32, -38, 64, 21, 250, 69)			//03 Eggman 2 S1

	SpriteFrame(-28, -34, 60, 20, 230, 166)			//04 Eggman 1 S2
	SpriteFrame(-28, -34, 60, 20, 230, 187)			//05 Eggman 2 S2

	SpriteFrame(-32, -38, 64, 21, 315, 69)			//06 Egg Robo S1
	SpriteFrame(-28, -34, 60, 20, 291, 187)			//07 Egg Robo S2
end event

event RSDKDraw
    DrawSprite(0)
end event

event RSDKLoad
    LoadSpriteSheet("Global/Display.gif")
    SpriteFrame(-16, -16, 32, 32, 223, 172)
end event